home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Tools - Objects / C++ / MPW C++ 3.1b1 / Scripts / CreateMake < prev   
Text File  |  1989-06-19  |  10KB  |  355 lines

  1. #    CreateMake - create a program makefile
  2. #
  3. #    Usage:
  4. #        CreateMake [ -Application [ -c creator ] | -Tool | -DA |
  5. #            -CR -m mainEntryPoint -rt resourceType 
  6. #            [ -t type ] [ -c creator ] ] [-sym on] program file…
  7. #
  8. #    Script CreateMake creates a simple MakeFile for building the specified
  9. #    program.  The program parameter is the name of the program.  Makefile
  10. #    <program>.make is created.  The default program type is Application.
  11. #    The program may be written in any combination of Assembly Language, C, C++
  12. #    Pascal, and/or Rez.    The list of files may include both source in
  13. #    these languages and library object files that don't appear below.
  14. #
  15. #    CreateMake links the program with the following set of MPW Libraries:
  16. #
  17. #        Inside Macintosh Interfaces
  18. #            {Libraries}Interface.o    
  19. #    
  20. #        Runtime support - one of the following:
  21. #            {Libraries}Stubs.o            # building a tool
  22. #            {Libraries}Runtime.o         # no C object files
  23. #            {CLibraries}CRuntime.o        # any C or C++ object files
  24. #
  25. #        C Libraries - if any source is in C
  26. #            {CLibraries}StdCLib.o
  27. #            {CLibraries}CSANELib.o
  28. #            {CLibraries}Math.o
  29. #            {CLibraries}CInterface.o
  30. #
  31. #        C++ Libraries - if any source is in C++
  32. #            {Clibraries}Streams.o        
  33. #            {Clibraries}CPlusLib.o
  34. #            {CLibraries}StdCLib.o
  35. #            {CLibraries}CSANELib.o
  36. #            {CLibraries}Math.o
  37. #            {CLibraries}CInterface.o
  38. #
  39. #        Pascal Libraries - if any source is in Pascal
  40. #            {PLibraries}PasLib.o
  41. #            {PLibraries}SANELib.o
  42. #
  43. #        For tools:
  44. #            {Libraries}ToolLibs.o
  45. #
  46. #        For desk accessories:
  47. #            {Libraries}DRVRRuntime.o
  48. #
  49. #
  50. #    Copyright Apple Computer, Inc. 1987-1988
  51. #    All rights reserved.
  52.  
  53.  
  54. Set Exit 0
  55. Set CaseSensitive 0
  56. Set type Application
  57. Set creator '????'
  58. Set runtime '{Libraries}Runtime.o'
  59. Set interface '{Libraries}Interface.o'
  60. Unset sources clibs plibs toollibs DRVRRuntime resource objects program suffix typ
  61. Unset cSeen tSeen rtSeen mSeen multipleType typeSpec CPls CLang symarg symseen compileOptions
  62.  
  63. #    Collect the script parameters.
  64. Loop
  65.     Break if {#} == 0
  66.     If "{1}" =~ /-Application/
  67.         Set type Application
  68.         Unset toollibs
  69.         If {typeSpec} == 0
  70.             Set typeSpec 1
  71.         Else
  72.             Set multipleType 1
  73.         End
  74.         shift 1
  75.         continue
  76.     Else If "{1}" =~ /-Tool/
  77.         Set type Tool
  78.         Set toollibs '{Libraries}ToolLibs.o'
  79.         If {typeSpec} == 0
  80.             Set typeSpec 1
  81.         Else
  82.             Set multipleType 1
  83.         End
  84.         shift 1
  85.         continue
  86.     Else If "{1}" =~ /-DA/
  87.         Set type DA
  88.         Unset toollibs
  89.         If {typeSpec} == 0
  90.             Set typeSpec 1
  91.         Else
  92.             Set multipleType 1
  93.         End
  94.         shift 1
  95.         continue
  96.     Else If "{1}" =~ /-CR/
  97.         Set type CR
  98.         Unset toollibs
  99.         If {typeSpec} == 0
  100.             Set typeSpec 1
  101.         Else
  102.             Set multipleType 1
  103.         End
  104.         shift 1 
  105.         continue
  106.     Else if "{1}" =~ /-c/
  107.         set creator "{2}"
  108.         set cseen 1
  109.         shift 2
  110.         continue
  111.     Else if "{1}" =~ /-t/
  112.         set typ "{2}"
  113.         set tseen 1
  114.         shift 2
  115.         continue
  116.     Else if "{1}" =~ /-rt/
  117.         set rtype "{2}"
  118.         set rtseen 1
  119.         shift 2
  120.         continue
  121.     Else if "{1}" =~ /-m/
  122.         set mentry "{2}"
  123.         set mseen 1
  124.         shift 2
  125.         continue
  126.     Else if "{1}" =~ /-sym/
  127.         set symarg {2}
  128.         set symseen 1
  129.         shift 2
  130.         continue
  131.     Else If ("{1}" =~ /≈.[acpr]/ || "{1}" =~ /≈.cp/)
  132.         Set sources "{sources}'{1}' "
  133.         shift 1
  134.         continue
  135.     Else If "{1}" =~ /≈.[o]/
  136.         Set objects "{objects}'{1}' "
  137.         shift 1
  138.         continue
  139.     Else If "{program}" == "" && "{1}" !~ /-≈/
  140.         Set program "{1}"
  141.         shift 1
  142.         continue
  143.     Else If "{1}" =~ /-≈/
  144.         Echo "### {0} - ∂"{1}∂" is not an option." > Dev:StdErr
  145.         Echo "# Usage - {0} [ -Application | -Tool | -DA | -CR -m mainEntryPoint ∂n ∂
  146.             -rt resourceType [ -c creator ] [ -f fileType ] ] [-sym on] program file…" > Dev:StdErr
  147.         Exit 1
  148.     Else
  149.         Echo "### {0} - Files must end in .a, .c, .p, .cp, .r, or .o." > Dev:StdErr
  150.         Echo "# Usage - {0} [ -Application | -Tool | -DA | -CR -m mainEntryPoint ∂n ∂
  151.             -rt resourceType [ -c creator ] [ -f fileType ] ] [-sym on] program file…" > Dev:StdErr
  152.         Exit 1
  153.     End
  154. End
  155. If {type} == CR && ("{rtype}" == "" || "{mentry}" == "")
  156.     Echo "### {0} - Options -rt and -m are required for code resource." > Dev:StdErr
  157.     Echo "# Usage - {0} [ -Application | -Tool | -DA | -CR -m mainEntryPoint ∂n ∂
  158.             -rt resourceType [ -c creator ] [ -f fileType ] ] [-sym on] program file…" > Dev:StdErr
  159.     Exit 1
  160. End
  161. If "{program}" == ""
  162.     Echo "### {0} - A program name is required." > Dev:StdErr
  163.     Echo "### {0} - Don't include the .a, .c, .cp, or .p suffix." > Dev:StdErr
  164.     Echo "# Usage - {0} [ -Application | -Tool | -DA | -CR -m mainEntryPoint ∂n ∂
  165.             -rt resourceType [ -c creator ] [ -f fileType ] ] [-sym on] program file…" > Dev:StdErr
  166.     Exit 1
  167. End
  168. If "{sources}" == ""
  169.     Echo "### {0} - A source file is required." > Dev:StdErr
  170.     Echo "# Usage - {0} [ -Application | -Tool | -DA | -CR -m mainEntryPoint ∂n ∂
  171.             -rt resourceType [ -c creator ] [ -f fileType ] ] [-sym on] program file…" > Dev:StdErr
  172.     Exit 1
  173. End
  174. If {multipleType} != 0
  175.     Echo "### {0} - Warning: More than one of Application, DA, Tool, or CR was specified. ∂n ∂
  176.     The last one on the command line will apply." > Dev:StdErr
  177. End
  178. If {cSeen} != 0 && ({type} == Tool || {type} == DA)
  179.         Echo "### {0} - Warning: Option -c ignored for {type}." > Dev:StdErr
  180. End
  181. If {tseen} != 0 && {type} != CR
  182.         Echo "### {0} - Warning: Option -t ignored for {type}." > Dev:StdErr
  183. End
  184. If {rtseen} != 0 && {type} != CR
  185.         Echo "### {0} - Warning: Option -rt ignored for {type}." > Dev:StdErr
  186. End
  187. If {mseen} != 0 && {type} != CR
  188.         Echo "### {0} - Warning: Option -m ignored for {type}." > Dev:StdErr
  189. End
  190. If {type} == Tool
  191.     Set options "-w -c 'MPS ' -t 'MPST'"
  192. Else If {type} == Application
  193.     Set options "-w -t 'APPL' -c '{creator}'"
  194. End
  195.  
  196. #    Create the heading at the top of the makefile.
  197.  
  198. Begin
  199.     Echo -n '#   File:       '; Quote "{program}".make
  200.     Echo -n '#   Target:     '; Quote "{program}"
  201.     If "{sources}" =~ /≈«1,80»/
  202.         Echo -n '#   Sources:    '; Quote  {sources}
  203.     Else
  204.         Set heading '#   Sources:    '
  205.         For i In {sources}
  206.             Echo -n "{heading}"
  207.             Quote "{i}"
  208.             Set heading '#               '
  209.         End
  210.     End
  211.     Echo -n '#   Created:    '; Date
  212.     Echo
  213.     Echo
  214.  
  215. #    Create list of implicit objects
  216.  
  217.     For file in {sources}
  218.         If "{file}" =~ /≈.[acp]/ || "{file}" =~ /≈.cp/
  219.             Set objects "{objects} '{file}.o' "
  220.         End
  221.     End
  222.  
  223. # generate OBJECTS definitions
  224.  
  225.     quote -n OBJECTS =
  226.     If "{objects}" =~ /?«1,80»/
  227.         Echo -n " "; Quote {objects}
  228.     Else
  229.         For i In {objects}
  230.             Echo ' ∂'
  231.             Echo -n ∂t∂t; Quote -n "{i}"
  232.         End
  233.         Echo
  234.     End
  235.     Echo
  236.     
  237. #    Generate Asm, C, C++, Pascal, and Rez rules.
  238.  
  239.     If {symseen} == 1
  240.         Set compileOptions "-sym {symarg}"
  241.     End
  242.     
  243.     For file in {sources}
  244.         If "{file}" =~ /≈.r/
  245.             Set resource "{file}"
  246.             If {type} == DA
  247.                 Quote "{program}" ƒ "{program}".make "{program}".DRVW "{file}"
  248.                 Echo -n ∂t; Quote Rez -rd -c DMOV -t DFIL "{file}" -o "{program}"
  249.                 Set DRVRruntime '{Libraries}DRVRRuntime.o'
  250.             Else
  251.                 Quote "{program}" ƒƒ "{program}".make "{file}"
  252.                 Echo -n ∂t; Quote Rez "{file}" -append -o "{program}"
  253.             End
  254.         End
  255.     End
  256.     Echo
  257.     
  258.     
  259.  
  260.     For file in {sources}
  261.         If "{file}" =~ /≈.a/
  262.             Quote "{file}".o ƒ "{program}".make "{file}"
  263.             Echo -n ∂t Asm "{compileoptions} "; Quote "{file}"
  264.         Else If "{file}" =~ /≈.c/ 
  265.             Quote "{file}".o ƒ "{program}".make "{file}"
  266.             If {type} == CR
  267.                 Echo -n ∂t C -b "{compileoptions} "; Quote "{file}"
  268.             Else
  269.                 Echo -n ∂t C "{compileoptions} "; Quote "{file}"
  270.             End
  271.             Set runtime '{CLibraries}CRuntime.o'
  272.             Set CLang 1
  273.         Else If "{file}" =~ /≈.cp/
  274.             Quote "{file}".o ƒ "{program}".make "{file}"
  275.             Echo -n ∂t CPlus "{compileoptions} "; Quote "{file}"
  276.             Set runtime '{CLibraries}CRuntime.o'
  277.             Set clibs '{CLibraries}StdCLib.o {CLibraries}CSANELib.o ∂
  278.                 {CLibraries}Math.o {CLibraries}CInterface.o ∂
  279.                 {CLibraries}CPlusLib.o ∂#{CLibraries}Complex.o'
  280.             Set CPls 1
  281.         Else If "{file}" =~ /≈.p/
  282.             Quote "{file}".o ƒ "{program}".make "{file}"
  283.             Echo -n ∂t Pascal "{compileoptions} "; Quote "{file}"
  284.             Set plibs '{PLibraries}PasLib.o {PLibraries}SANELib.o'   
  285.         End
  286.         If {CPls} == 1
  287.              Set clibs '{CLibraries}StdCLib.o {CLibraries}CSANELib.o ∂
  288.                 {CLibraries}Math.o {CLibraries}CInterface.o ∂
  289.                 {CLibraries}CPlusLib.o ∂#{CLibraries}Complex.o'
  290.         Else If {CLang} == 1
  291.             Set  clibs '{CLibraries}StdCLib.o {CLibraries}CSANELib.o ∂
  292.                 {CLibraries}Math.o {CLibraries}CInterface.o ∂#{CLibraries}Complex.o'
  293.         End
  294.     End
  295.     Echo
  296.     
  297.     If {type} == Tool;
  298.         set runtime "∂{Libraries∂}Stubs.o {runtime}"
  299.     End
  300.  
  301.     If {type} == DA
  302.         If "{resource}" == ""
  303.             Set options "-w -t '????' -c '????' -rt DRVR=12 -sg '{program}'"
  304.         Else
  305.             Set options "-w -t '????' -c '????' -rt DRVR=0 -sg '{program}'"
  306.         End
  307.         Quote -n "{program}".DRVW ƒ "{program}".make
  308.         Echo ∂ ∂{OBJECTS∂}
  309.         Set suffix '.DRVW'
  310.     Else If {type} == CR
  311.         Quote -n "{program}" ƒ "{program}".make
  312.         Echo ∂ ∂{OBJECTS∂}
  313.         If {typ} == 0
  314.             set typ '????'
  315.         End
  316.         Set options "-w -t '{typ}' -c '{creator}' -rt '{rtype}' -m '{mentry}' ∂
  317.            -sg '{program}'"
  318.     Else
  319.         Quote -n "{program}" ƒƒ "{program}".make
  320.         Echo ∂ ∂{OBJECTS∂}
  321.     End
  322.     
  323. #    Generate Link rule.
  324.     
  325.     If {symseen} == 1
  326.         Set options "{options} -sym {symarg} -mf"
  327.     End
  328.     Echo -n ∂t; Quote -n Link {options}; Echo ' ∂'
  329.     If {CPls} ==1
  330.         For i in {runtime}
  331.             If "{i}" =~ /(≈)®1(∂{≈∂})®2(≈)®3/    # contains {}s ?
  332.                 Echo -n ∂t∂t; Echo "{®1}∂"{®2}∂"{®3}" ∂∂
  333.             Else
  334.                 Echo -n ∂t∂t; Quote -n "{i}"; Echo ' ∂'
  335.             End
  336.         End
  337.         unset runtime
  338.     End
  339.     Echo -n ∂t∂t; Echo -n ∂{OBJECTS∂}; Echo ' ∂'
  340.     For i In {DRVRRuntime} {runtime} {interface} {clibs} {plibs} {toollibs}
  341.         If "{i}" =~ /(≈)®1(∂{≈∂})®2(≈)®3/    # contains {}s ?
  342.             Echo -n ∂t∂t; Echo "{®1}∂"{®2}∂"{®3}" ∂∂
  343.         Else
  344.             Echo -n ∂t∂t; Quote -n "{i}"; Echo ' ∂'
  345.         End
  346.     End
  347.     Echo -n ∂t∂t; Quote -o "{program}{suffix}"
  348. End > "{program}".make
  349. Echo "{program}"
  350.  
  351.  
  352.  
  353.  
  354.  
  355.